package game.models;

import map.PlayerEntity;
import map.SurfaceLevel;

public class RunningMovementBehaviour implements MovementBehaviour {

	private PlayerEntity player;
	private SurfaceLevel activeSurfaceLevel;
	
	public RunningMovementBehaviour(PlayerEntity player){
		this.player = player;
		activeSurfaceLevel = player.getMapTerrain(player.getCurX(), player.getCurY()).getSurfaceLevel();
	}
	
	@Override
	public boolean moveLeft() {
		if(player.getMapTerrain(player.getCurX()-1, player.getCurY()).getSurfaceLevel() == activeSurfaceLevel){
			return player.moveAction(player.getCurX()-1, player.getCurY());
		}
		return false;
	}

	@Override
	public boolean moveRight() {
		if(player.getMapTerrain(player.getCurX()+1, player.getCurY()).getSurfaceLevel() == activeSurfaceLevel){
			return player.moveAction(player.getCurX()+1, player.getCurY());
		}
		return false;
	}

	@Override
	public boolean moveUp() {
		if(player.getMapTerrain(player.getCurX(), player.getCurY()-1).getSurfaceLevel() == activeSurfaceLevel){
			return player.moveAction(player.getCurX(), player.getCurY()-1);
		}
		return false;
	}

	@Override
	public boolean moveDown() {
		if(player.getMapTerrain(player.getCurX(), player.getCurY()+1).getSurfaceLevel() == activeSurfaceLevel){
			return player.moveAction(player.getCurX(), player.getCurY()+1);
		}
		return false;
	}

}
